﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Description;


namespace advadev.DataStorage
{

    /// <summary>
    /// Must be implemented from each data storage service
    /// </summary>
    [ServiceContract]
    public interface IDataStorageService
    {

        /// <summary>
        /// When implemented, saves the given generic entity
        /// </summary>
        /// <param name="genericEntity">
        /// Generic entity to save
        /// </param>
        [OperationContract(Name = "SaveItem")]
        void Save(GenericEntity genericEntity);

        /// <summary>
        /// When implemented, saves the given list of generic entities
        /// </summary>
        /// <param name="genericEntities">
        /// List of generic entities to save
        /// </param>
        [OperationContract(Name = "SaveList")]
        void Save(IList<GenericEntity> genericEntities);

        /// <summary>
        /// When implemented, finds the generic entity with the given id, application
        /// key and type
        /// </summary>
        /// <param name="id">
        /// Id of the generic entity
        /// </param>
        /// <param name="applicationKey">
        /// Application key
        /// </param>
        /// <param name="fullClassName">
        /// Full class name of the type
        /// </param>
        /// <returns>
        /// The generic entity or null
        /// </returns>
        [OperationContract(Name = "FindItem")]
        GenericEntity Find(string id, string applicationKey, string fullClassName);

        /// <summary>
        /// When implemented, selects all generic entities with the given
        /// application key and type
        /// </summary>
        /// <param name="applicationKey">
        /// Application key
        /// </param>
        /// <param name="fullClassName">
        /// Full class name of the type
        /// </param>
        /// <returns>
        /// A list of generic entities
        /// </returns>
        [OperationContract(Name = "SelectList")]
        IList<GenericEntity> Select(string applicationKey, string fullClassName);

        /// <summary>
        /// When implemented, deletes the given generic entity
        /// </summary>
        /// <param name="genericEntity">
        /// Generic entity to delete
        /// </param>
        [OperationContract(Name = "DeleteItem")]
        void Delete(GenericEntity genericEntity);

        /// <summary>
        /// When implemented, deletes the given list of generic entities
        /// </summary>
        /// <param name="genericEntities">
        /// List of generic entities to delete
        /// </param>
        [OperationContract(Name = "DeleteList")]
        void Delete(IList<GenericEntity> genericEntities);

        /// <summary>
        /// When implemented, deletes all generic entities with the given
        /// application key and type
        /// </summary>
        /// <param name="applicationKey">
        /// Application key
        /// </param>
        /// <param name="fullClassName">
        /// Full class name of the type
        /// </param>
        [OperationContract(Name = "DeleteAllOfType")]
        void Delete(string applicationKey, string fullClassName);

        /// <summary>
        /// When implemented, deletes all generic entities with the given
        /// application key
        /// </summary>
        /// <param name="applicationKey">
        /// Application key
        /// </param>
        [OperationContract(Name = "DeleteAllOfApplication")]
        void Delete(string applicationKey);

        /// <summary>
        /// When implemented, finds all full class names with the given
        /// application key
        /// </summary>
        /// <param name="applicationKey">
        /// Application key
        /// </param>
        /// <returns>
        /// List of full class names or empty list
        /// </returns>
        [OperationContract(Name = "FindFullClassNames")]
        IList<string> FindFullClassNames(string applicationKey);

        /// <summary>
        /// When implemented, finds all application keys
        /// </summary>
        /// <param name="administratorCredentials">
        /// Administrator credentials
        /// </param>
        /// <returns>
        /// List of application keys or empty list
        /// </returns>
        [OperationContract(Name = "FindApplicationKeys")]
        IList<string> FindApplicationKeys(ClientCredentials administratorCredentials);

    }

}
